#include "stdafx.h"
#include "CFSXGUI.h"

extern HWND g_hWnd; 
extern void SetAddonMenuText(char *Text);

#define CONNECT_TEXT "Connect to VATSIM..."
#define DISCONNECT_TEXT "Disconnect from VATSIM"

CFSXGUI::CFSXGUI() : m_bMenuUp(false)
{
}

CFSXGUI::~CFSXGUI()
{
}

void CFSXGUI::Initialize()
{
	m_hFSXWindow = FindWindow(L"FS98MAIN", NULL);
	m_Graphics.Initialize();
	SetAddonMenuText(CONNECT_TEXT);

	//Preload the bitmaps
	m_Graphics.LoadBitmapFromFile(L"f:\\dev\\VPC\\src\\Debug\\Bitmap.bmp", &m_bmLogin); //DEBUG

	return;
}

void CFSXGUI::Shutdown()
{
	m_bMenuUp = false;
	m_Graphics.DeleteBitmap(&m_bmLogin);
	m_Graphics.Shutdown();

	return;
}

//FSX has finished drawing... add our overlay (if showing) given FSX's Direct 3D interface.
void CFSXGUI::OnFSXPresent(IDirect3DDevice9 *pI)
{
	if (!m_bMenuUp)
		return;

	m_Graphics.DrawBitmap(pI, &m_bmLogin, 10, 80);

	return;
}

//FSX has gone into flight mode
void CFSXGUI::OnFSXSimRunning()
{
	return;
}

//FSX has gone out of flight mode
void CFSXGUI::OnFSXSimStopped()
{
	m_bMenuUp = false;
	return;
}

//User has selected FSX addon menu (Connect to VATSIM or Disconnect From Vatsim)
void CFSXGUI::OnFSXAddonMenuSelected()
{
	m_bMenuUp = !m_bMenuUp;
	if (!m_bMenuUp)
		SetAddonMenuText(CONNECT_TEXT);
	else
		SetAddonMenuText(DISCONNECT_TEXT);

	return;
}